<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
      /* 
      const arrList = [1,2,1,3,2,4,5,5,4,6]
      要求 : 编写代码去重
      实现方法二 : 采用数组非破坏性方法indexof
    */
    const arrList = [1,2,1,3,2,4,5,5,4,6]
    for(let i = 0 ; i < arrList.length ; i++) {
       let index = arrList.indexOf(arrList[i],i+1)
       if( index != -1){
          arrList.splice(index,1)
          i--
       }
    }
    console.log(arrList);
    // 实现方法三  : 采用一个新的数组来存储元素,对原数组进行非破坏性操作
    const newArrList = []
    arrList.forEach( item =>{
      if(newArrList.indexOf(item) === -1){
        newArrList.push(item)
      }         
    })
    console.log(arrList);
  </script>
</body>
</html>